package com.wufan.day02;

/**
 * 数组的冒泡排序的实现
 * @author SongWufan
 * @date 2021/3/5 19:01
 */
public class BubbleSortTest {
    public static void main(String[] args) {
        int[] arr = new int[]{12,23,66,13,46,88,34,97,75,-86};
        //冒泡排序
        sort(arr);

        for (int j = 0; j < arr.length; j++){
            System.out.print(arr[j] + "\t");
        }
    }

    public static void sort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++){
            for (int j = 0; j < arr.length - 1 - i; j++){
                if (arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
}
